using System.Collections.Generic;
using AzureContrib.WindowsAzure.Utils;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace AzureContrib.WindowsAzure.ServiceRuntime
{
	internal class RoleInstanceWrapper : IRoleInstance
	{
		private readonly RoleInstance roleInstance;

		public RoleInstanceWrapper(RoleInstance roleInstance)
		{
			this.roleInstance = roleInstance;
		}

		public string Id
		{
			get { return roleInstance.Id; }
		}

		public int UpdateDomain { get { return roleInstance.UpdateDomain; } }

		public int FaultDomain { get { return roleInstance.FaultDomain; } }

		public IRole Role { get { return new RoleWrapper(roleInstance.Role); } }

		public IDictionary<string, IRoleInstanceEndpoint> InstanceEndpoints
		{
			get
			{
				var roleInstanceEndpoints = new Dictionary<string, IRoleInstanceEndpoint>();
				roleInstance.InstanceEndpoints.ForEach(keyValuePair => roleInstanceEndpoints.Add(keyValuePair.Key, new RoleInstanceEndpointWrapper(keyValuePair.Value)));
				return roleInstanceEndpoints;
			}
		}
	}
}